package com.gomore.opple.module.searchgoods;

import android.os.Bundle;

import com.gomore.opple.R;
import com.gomore.opple.module.BaseActivity;
import com.gomore.opple.module.IntentStart;

import javax.inject.Inject;

/**
 * Created by asus on 2017/5/9.
 */
public class SearchGoodsActivity extends BaseActivity {
    @Inject
    SearchGoodsPresenter searchGoodsPresenter;

    private SearchGoodsFragment searchGoodsFragment;
    private String key;

    @Override
    protected void initalizeViewData() {
        super.initalizeViewData();
        if (getIntent() != null) {
            key = getIntent().getStringExtra(IntentStart.SEARCHKEY);
        }
    }

    @Override
    protected void initalizeViews() {
        if (searchGoodsFragment == null) {
            searchGoodsFragment = SearchGoodsFragment.getInstance();
            Bundle bundle = new Bundle();
            bundle.putString(IntentStart.SEARCHKEY, key);
            searchGoodsFragment.setArguments(bundle);
            replaceFragment(searchGoodsFragment, false, "add_search_goods_view");
        }
    }

    @Override
    protected void initializeDependencyInjector() {
        DaggerSearchGoodsComponent.builder()
                .dataRepositoryComponent(getRepositoryComponent())
                .searchGoodsPresenterModule((new SearchGoodsPresenterModule(searchGoodsFragment)))
                .build()
                .inject(this);
    }

    @Override
    protected int getLayoutView() {
        return R.layout.activity_search_goods;
    }

}
